package com.czl.module_storehouse.mvp.presenter;

import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.presenter.BasePresenter;
import com.czl.module_base.observer.AbsHandleSubscriber;
import com.czl.base.data.bean.tengyun.ReceiveBean;
import com.czl.module_storehouse.bean.ReceiveInfoBean;
import com.czl.module_storehouse.mvp.model.ReceiveModel;
import com.czl.module_storehouse.mvp.view.ReceiveView;

/**
 * @author xubin
 */
public class ReceivePresenter extends BasePresenter<ReceiveModel, ReceiveView> {

    public static final String TAG_RECEIVE_ADD_INFO = "receive_add_info";

    /**
     * 查询待领出领用单
     */
    public void getNeedDealtReceiveList(ReceiveInfoBean bean) {
        doSubscribe(mModel.getNeedDealtReceiveList(bean), new AbsHandleSubscriber<HttpResponse<ListBean<ReceiveBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<ReceiveBean>> httpResponse) {
                mView.showData(httpResponse.getData());
            }
        }, true);
    }

    /**
     * 直接领用出库操作
     *
     * @param bean
     */
    public void addReceiveInfo(ReceiveInfoBean bean) {
        doSubscribe2(mModel.addReceiveInfo(bean), new AbsHandleSubscriber<HttpResponse<Object>>() {
            @Override
            public void onSuccess(HttpResponse<Object> httpResponse) {
                httpResponse.setRequestTag(TAG_RECEIVE_ADD_INFO);
                mView.showHttpResponse(httpResponse);
            }
        });
    }

    /**
     * 申请领用出库操作
     *
     * @param bean
     */
    public void editReceiveInfo(ReceiveInfoBean bean) {
        doSubscribe2(mModel.editReceiveInfo(bean), new AbsHandleSubscriber<HttpResponse<Object>>() {
            @Override
            public void onSuccess(HttpResponse<Object> httpResponse) {
                mView.showHttpResponse(httpResponse);
            }
        });
    }
}
